package com.wd.live.viewmodel

import HttpUtils
import android.util.Log
import androidx.lifecycle.MutableLiveData
import com.wd.live.model.base.BaseViewModel
import com.wd.live.model.bean.TypeBean
import com.wd.live.model.bean.ZhiBoListBean
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

/**
 * 作者：马海钊
 * 时间：2023/8/18 11:21
 * 功能：广场
 */
class ListViewModel :BaseViewModel(){
    //直播列表
    public var liveMutableLiveData=MutableLiveData<ZhiBoListBean>()
    fun getLive(liveType:Int,page:Int,size:Int){
        var params=HashMap<String,Any>()
        params["liveType"]=liveType
        params["page"]=page
        params["size"]=size

        HttpUtils.api.live(params)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe ({
                   liveMutableLiveData.postValue(it)
            }, { error ->
                Log.d("userlianmaiError", error.message.toString())
            })
    }

    //顶部导航
    public var typeMutableLiveData=MutableLiveData<TypeBean>()
    fun getType(){
        HttpUtils.api.tabtype().subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe({
                typeMutableLiveData.postValue(it)
            }, { error ->
                Log.d("userlianmaiError", error.message.toString())
            })
    }

}